Fix bug #486369, by passing the selection info along when pasting.
authorRichard Hult <richard@imendio.com>
Sat, 3 Nov 2007 13:12:45 +0000 (13:12 +0000)
committerRichard Hult <rhult@src.gnome.org>
Sat, 3 Nov 2007 13:12:45 +0000 (13:12 +0000)
2007-11-03  Richard Hult  <richard@imendio.com>

* gtk/gtkclipboard-quartz.c: (clipboard_owner_destroyed),
(gtk_clipboard_set_contents), (clipboard_unset): Fix bug #486369,
by passing the selection info along when pasting.

svn path=/trunk/; revision=18965

ChangeLog
gtk/gtkclipboard-quartz.c

index dc2785b554b22d2029e023fadb315e36362f09a8..9b8a532c9d1e5d82eaec5f71ea2d85812cec7296 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-03  Richard Hult  <richard@imendio.com>
+
+       * gtk/gtkclipboard-quartz.c: (clipboard_owner_destroyed),
+       (gtk_clipboard_set_contents), (clipboard_unset): Fix bug #486369,
+       by passing the selection info along when pasting.
+
 2007-11-03  Richard Hult  <richard@imendio.com>
 
        * gdk/quartz/GdkQuartzWindow.c:
index e86feeffa122cfed37b58e5e92fc292adac3d89c..24563f24074f951af408618db67cd9c6ddbbc5a1 100644 (file)
@@ -53,6 +53,7 @@ struct _GtkClipboard
   GtkClipboardClearFunc clear_func;
   gpointer user_data;
   gboolean have_owner;
+  GtkTargetList *target_list;
 
   gboolean have_selection;
   GdkDisplay *display;
@@ -91,18 +92,26 @@ struct _GtkClipboardClass
 -(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
 {
   GtkSelectionData selection_data;
+  guint info;
 
   selection_data.selection = clipboard->selection;
   selection_data.data = NULL;
   selection_data.target = _gtk_quartz_pasteboard_type_to_atom (type);
 
-  /* FIXME: We need to find out what the info argument should be
-   * here by storing it in the clipboard object in
-   * gtk_clipboard_set_contents
-   */
-  clipboard->get_func (clipboard, &selection_data, 0, clipboard->user_data);
+  if (clipboard->target_list &&
+      gtk_target_list_find (clipboard->target_list, selection_data.target, &info))
+    {
+      clipboard->get_func (clipboard, &selection_data,
+                           info,
+                           clipboard->user_data);
+    }
+  else
+    {
+      selection_data.length = -1;
+    }
 
-  _gtk_quartz_set_selection_data_for_pasteboard (clipboard->pasteboard, &selection_data);
+  _gtk_quartz_set_selection_data_for_pasteboard (clipboard->pasteboard,
+                                                 &selection_data);
 
   g_free (selection_data.data);
 }
@@ -326,6 +335,12 @@ clipboard_owner_destroyed (gpointer data)
       clipboard->user_data = NULL;
       clipboard->have_owner = FALSE;
 
+      if (clipboard->target_list)
+        {
+          gtk_target_list_unref (clipboard->target_list);
+          clipboard->target_list = NULL;
+        }
+
       gtk_clipboard_clear (clipboard);
 
       tmp_list = tmp_list->next;
@@ -385,11 +400,15 @@ gtk_clipboard_set_contents (GtkClipboard         *clipboard,
   clipboard->get_func = get_func;
   clipboard->clear_func = clear_func;
 
+  if (clipboard->target_list)
+    gtk_target_list_unref (clipboard->target_list);
+  clipboard->target_list = gtk_target_list_new (targets, n_targets);
+
   [clipboard->pasteboard declareTypes:types owner:owner];
 
   [pool release];
 
-  return true;
+  return TRUE;
 }
 
 /**
@@ -521,6 +540,12 @@ clipboard_unset (GtkClipboard *clipboard)
   if (old_clear_func)
     old_clear_func (clipboard, old_data);
 
+  if (clipboard->target_list)
+    {
+      gtk_target_list_unref (clipboard->target_list);
+      clipboard->target_list = NULL;
+    }
+
   /* If we've transferred the clipboard data to the manager,
    * unref the owner
    */